<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>

    // foreach遍历数组
    var arr = [1, 2, 3];
    arr.forEach(function (currentValue, index, array) {
        console.log("currentValue:" + currentValue);
        console.log("index:" + index);
        console.log("this array:" + array);
    });

    console.log("==================================");
    // filter 筛选数组，返回新数组
    var arr = [11, 22, 33, 55, 66, 77, 88];
    var newArr = arr.filter(function (value, index, array) {
        // return value > 33;
        return value % 2 == 0;
    });
    console.log(newArr);
    var newArr = arr.filter(function (value, index, array) {
        return index > 1;
    });
    console.log(newArr);

    console.log("==================================");
    // some 判断数组中是否有元素满足条件，若碰到第一个满足条件的，则终止循环。因为效率高
    var arr = ["red", "pink", "blue", "black", "green"];

    var flag = arr.some(function (value, index, array) {
        return value === "pink";
    });

    console.log(flag)

    console.log("==================================");
    // TODO map的用法


    console.log("==================================");
    // TODO every的用法


</script>
</body>
</html>